<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // var a = 100;

        // function m1() {
        //     var a = 200;

        //     function m2() {
        //         console.log(a); //200
        //     }
        //     m2();
        //     console.log(a); //200
        // }
        // m1();
        // console.log(a); //100

        var arr =[12,54,8,32,7,8,8,8,7];
    function findMax(arr){
       var count =0,
       max = 1,
       curValue = arr[0];
        for(var i = 0;i<arr.length;i++){
            var cur = arr[i];
            for(var j = i;j<arr.length;j++){
                if(cur == arr[j]){
                   count++;
                }
            }
            if(count>max){
                curValue = cur;
                max = count;
            }
            count = 0;
        }
        console.log("最多出现的元素是:",curValue,"出现了"+max+"次");
    }
   // findMax(arr);
   var a=[1,2],
       b=[3];
    function merge(arr1,arr2){
                var a1Len = arr1.length;
                var a2Len = arr2.length;
                var res = [];
                for(var i = 0 ; i <a1Len;i++){
                    res.push(arr1[i]);
                }
                for(var i = 0; i<a2Len;i++){
                    res.push(arr2[i]);
                }
                return res;
            }
            merge(a,b);

    </script>
</body>

</html>